package com.aliyun.messagemgt.repository;

import com.aliyun.messagemgt.converter.BaseTenantUserConverter;
import com.aliyun.messagemgt.domain.repository.IBaseTenantUserRepository;
import com.aliyun.messagemgt.dto.base.BaseTenantUserDTO;
import com.aliyun.messagemgt.entities.BaseTenantUser;
import com.aliyun.messagemgt.repository.mappers.BaseTenantUserMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 租户-用户关联表 服务实现类
 * </p>
 *
 * @author wugongzi
 * @since 2021-09-23
 */
@Service
public class BaseTenantUserMybatisRepository implements IBaseTenantUserRepository {

    @Autowired
    private BaseTenantUserMapper baseTenantUserMapper;
    @Override
    public List<BaseTenantUserDTO> getBaseTenantUserDTOByUserId(String userId) {
        QueryWrapper<BaseTenantUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        List<BaseTenantUser> baseTenantUserList = baseTenantUserMapper.selectList(queryWrapper);
        List<BaseTenantUserDTO> baseTenantUserDTOList = BaseTenantUserConverter.INSTANCE.baseTenantUserList2baseTenantUserDTOList(baseTenantUserList);
        return baseTenantUserDTOList;
    }
}
